<template>
  <div>
    <div class="title">
      <h3>推荐商品</h3>
    </div>
    <div class="items">
      <div class="item"
        @click="clickItem(item.id)"
        v-for="item in items" :key="item.id">
        <img class="item-pic"  v-lazy="item.pic" alt="">
        <div class="item-info">
          <h5>{{item.name}}</h5>
          <div class="item-price">
            <p class="price">
              ￥{{item.minPrice}}
            </p>
            <van-icon @click.stop="clickCartIcon(item.id)" name="gouwuche" size="30" class-prefix="icon"></van-icon>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    items: {
      type: Array,
      required: true
    }
  },
  methods: {
    clickItem (id) {
      this.$emit('clickItem', id)
    },
    clickCartIcon (id) {
      this.$emit('addCart', id)
    }
  }
}
</script>

<style lang="scss" scoped>
.title{
  h3{
    color: #333;
    font-size: 20px;
    text-align: center;
    margin: 10px 0;
  }
}
.items{
  padding:0 8px;
  .item{
    display: flex;
    background-color: #fff;
    border-radius: 0.1351rem;
    margin-bottom:10px;
    img{
      width: 4.8649rem;
      height: 4.8649rem;
    }
    .item-info{
       flex:1;
      padding:0 10px;
      h5{
        margin:0;
        color: #333;
        font-size: 16px;
        line-height: 40px;
      }
      .item-price{
        color: #ff734c;
        font-size: 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        p{
          margin:0;
        }
      }
    }
  }
}
</style>
